home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / iomon2.zip / IODISP.C < prev    next >
Text File  |  1991-06-10  |  2KB  |  62 lines

  1. /*-----------------------------------------------------------------------
  2. | iodisp.c - Display data captured with I/O Monitor                     |
  3. |            (must compile with -Zp to pack structures)                 |
  4. -----------------------------------------------------------------------*/
  5. #include <stdio.h>
  6. #include <bios.h>
  7. #include <dos.h>
  8.  
  9. #define FALSE 0
  10. #define TRUE 1
  11. #define USER_INT 0x61
  12. #define BUFFER_SIZE 8192
  13. #define INPUT           0
  14. #define OUTPUT          0x10
  15. #define ABYTE           1
  16. #define AWORD           2
  17. #define CONSTANT        8
  18. #define CONTAINS_DATA   0x80
  19.  
  20. struct buf_record       {
  21.                 unsigned char  io_attrib;
  22.                 unsigned short int io_port;
  23.                 unsigned short int io_data;
  24.                 };
  25. char * text_direc[]=      {"Read",
  26.                           "Write"};
  27. char * text_size[]=       {"Byte",
  28.                           "Word"};
  29. main()
  30. {
  31. struct buf_record far * buf_ptr;
  32. unsigned far * vector_ptr;
  33. union REGS inregs, outregs;
  34. unsigned x;
  35. register unsigned char attrib;
  36.  
  37.         vector_ptr=(unsigned far *) ((USER_INT << 2) + 2);    //cs of user isr  
  38.         if ( *vector_ptr == 0)          //if user int not installed
  39.         {
  40.                 printf ("%s", "IOM not installed.");
  41.                 exit(1);
  42.         }
  43.              
  44.            int86 ( USER_INT, &inregs, &outregs );  //do user int
  45.         FP_SEG(buf_ptr)=outregs.x.dx;
  46.         FP_OFF(buf_ptr)=outregs.x.bx;
  47.  
  48.         for (x=0;x< ( BUFFER_SIZE  / sizeof(struct buf_record)) && \
  49.              ((attrib=buf_ptr->io_attrib) & CONTAINS_DATA);x++,buf_ptr++)
  50.         {
  51.                 printf ("%s \t", text_direc[ (attrib & OUTPUT) >> 4 ]);
  52.                 printf ("%s \t", text_size[ (attrib & (AWORD | ABYTE)) -1 ]);
  53.                 printf ("%4x \t %4x \r\n", buf_ptr->io_port, buf_ptr->io_data);
  54.         }
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.